package com.itheima.d3_Exception;

import java.util.Scanner;

public class ExceptionTest {
    public static void main(String[] args) {
        while (true) {
            try {
                System.out.println(getMoney());
            } catch (java.lang.Exception e) {
                e.printStackTrace();
            }
        }
    }


    public static int getMoney(){
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("请输入金额：");
            int money = scanner.nextInt();
            if(money >= 0){
                return money;
            }else {
                System.out.println("金额不能为负数");
            }
        }
    }
}
